﻿USE [TicketAppDBNew]
GO
ALTER TABLE [dbo].[Payments] DROP CONSTRAINT [DF_Payments_SuccessfulPayment]
GO
ALTER TABLE [dbo].[Users] DROP CONSTRAINT [DF_Users_Status]
GO
/****** Object:  ForeignKey [FK_Addresses_Cities]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Addresses] DROP CONSTRAINT [FK_Addresses_Cities]
GO
/****** Object:  ForeignKey [FK_AgentBranchAddress]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[AgentBranches] DROP CONSTRAINT [FK_AgentBranchAddress]
GO
/****** Object:  ForeignKey [FK_UserAgentBranch]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[AgentBranches] DROP CONSTRAINT [FK_UserAgentBranch]
GO
/****** Object:  ForeignKey [FK_Events_EventUsers]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[EventsUsers] DROP CONSTRAINT [FK_Events_EventUsers]
GO
/****** Object:  ForeignKey [FK_EventsUsers_Users]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[EventsUsers] DROP CONSTRAINT [FK_EventsUsers_Users]
GO
/****** Object:  ForeignKey [FK_EventEventVenue]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[EventVenues] DROP CONSTRAINT [FK_EventEventVenue]
GO
/****** Object:  ForeignKey [FK_EventVenues_TicketTemplates]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[EventVenues] DROP CONSTRAINT [FK_EventVenues_TicketTemplates]
GO
/****** Object:  ForeignKey [FK_VenueEventVenue]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[EventVenues] DROP CONSTRAINT [FK_VenueEventVenue]
GO
/****** Object:  ForeignKey [FK_PaymentModePayment]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Payments] DROP CONSTRAINT [FK_PaymentModePayment]
GO
/****** Object:  ForeignKey [FK_UserPayment]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Payments] DROP CONSTRAINT [FK_UserPayment]
GO
/****** Object:  ForeignKey [FK_AgentBranchTicketQuota]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[TicketQuotas] DROP CONSTRAINT [FK_AgentBranchTicketQuota]
GO
/****** Object:  ForeignKey [FK_TicketTypeTicketQuota]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[TicketQuotas] DROP CONSTRAINT [FK_TicketTypeTicketQuota]
GO
/****** Object:  ForeignKey [FK_PaymentTicket]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Tickets] DROP CONSTRAINT [FK_PaymentTicket]
GO
/****** Object:  ForeignKey [FK_Tickets_AgentBranches]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Tickets] DROP CONSTRAINT [FK_Tickets_AgentBranches]
GO
/****** Object:  ForeignKey [FK_Tickets_TicketTypes]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Tickets] DROP CONSTRAINT [FK_Tickets_TicketTypes]
GO
/****** Object:  ForeignKey [FK_UserTicket]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Tickets] DROP CONSTRAINT [FK_UserTicket]
GO
/****** Object:  ForeignKey [FK_EventVenueTicketType]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[TicketTypes] DROP CONSTRAINT [FK_EventVenueTicketType]
GO
/****** Object:  ForeignKey [FK_UserAddress]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Users] DROP CONSTRAINT [FK_UserAddress]
GO
/****** Object:  ForeignKey [FK_UserRole]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Users] DROP CONSTRAINT [FK_UserRole]
GO
/****** Object:  ForeignKey [FK_VenueAddress]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Venues] DROP CONSTRAINT [FK_VenueAddress]
GO
/****** Object:  ForeignKey [FK_Venues_Contacts]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Venues] DROP CONSTRAINT [FK_Venues_Contacts]
GO
/****** Object:  Table [dbo].[TicketQuotas]    Script Date: 09/15/2011 00:01:52 ******/
DROP TABLE [dbo].[TicketQuotas]
GO
/****** Object:  Table [dbo].[Tickets]    Script Date: 09/15/2011 00:01:52 ******/
DROP TABLE [dbo].[Tickets]
GO
/****** Object:  Table [dbo].[TicketTypes]    Script Date: 09/15/2011 00:01:52 ******/
DROP TABLE [dbo].[TicketTypes]
GO
/****** Object:  Table [dbo].[Payments]    Script Date: 09/15/2011 00:01:52 ******/
DROP TABLE [dbo].[Payments]
GO
/****** Object:  Table [dbo].[AgentBranches]    Script Date: 09/15/2011 00:01:52 ******/
DROP TABLE [dbo].[AgentBranches]
GO
/****** Object:  Table [dbo].[EventsUsers]    Script Date: 09/15/2011 00:01:52 ******/
DROP TABLE [dbo].[EventsUsers]
GO
/****** Object:  Table [dbo].[EventVenues]    Script Date: 09/15/2011 00:01:52 ******/
DROP TABLE [dbo].[EventVenues]
GO
/****** Object:  Table [dbo].[Users]    Script Date: 09/15/2011 00:01:52 ******/
DROP TABLE [dbo].[Users]
GO
/****** Object:  Table [dbo].[Venues]    Script Date: 09/15/2011 00:01:52 ******/
DROP TABLE [dbo].[Venues]
GO
/****** Object:  Table [dbo].[Addresses]    Script Date: 09/15/2011 00:01:52 ******/
DROP TABLE [dbo].[Addresses]
GO
/****** Object:  Table [dbo].[PaymentModes]    Script Date: 09/15/2011 00:01:52 ******/
DROP TABLE [dbo].[PaymentModes]
GO
/****** Object:  Table [dbo].[Cities]    Script Date: 09/15/2011 00:01:52 ******/
DROP TABLE [dbo].[Cities]
GO
/****** Object:  Table [dbo].[Contacts]    Script Date: 09/15/2011 00:01:52 ******/
DROP TABLE [dbo].[Contacts]
GO
/****** Object:  Table [dbo].[Events]    Script Date: 09/15/2011 00:01:52 ******/
DROP TABLE [dbo].[Events]
GO
/****** Object:  Table [dbo].[Roles]    Script Date: 09/15/2011 00:01:52 ******/
DROP TABLE [dbo].[Roles]
GO
/****** Object:  Table [dbo].[TicketTemplates]    Script Date: 09/15/2011 00:01:52 ******/
DROP TABLE [dbo].[TicketTemplates]
GO
/****** Object:  Table [dbo].[TicketTemplates]    Script Date: 09/15/2011 00:01:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TicketTemplates](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Template] [nvarchar](max) NOT NULL,
	[Name] [nvarchar](100) NOT NULL,
 CONSTRAINT [PK_TicketTemplates] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Roles]    Script Date: 09/15/2011 00:01:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Roles](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](20) NOT NULL,
 CONSTRAINT [PK_Roles] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Events]    Script Date: 09/15/2011 00:01:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Events](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](100) NOT NULL,
	[StartDateTime] [datetime] NOT NULL,
	[EndDateTime] [datetime] NOT NULL,
	[Timezone] [nvarchar](50) NOT NULL,
	[Description] [nvarchar](max) NOT NULL,
	[Status] [smallint] NOT NULL,
	[ImageUrl] [nvarchar](max) NULL,
 CONSTRAINT [PK_Events] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Draft, 1=Active Event; 2=Paused; 3=Cancelled; 4=Complete' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Events', @level2type=N'COLUMN',@level2name=N'Status'
GO
/****** Object:  Table [dbo].[Contacts]    Script Date: 09/15/2011 00:01:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Contacts](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Phone] [nvarchar](max) NOT NULL,
	[Email] [nvarchar](max) NOT NULL,
	[Name] [nvarchar](max) NOT NULL,
 CONSTRAINT [PK_Contacts] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Cities]    Script Date: 09/15/2011 00:01:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Cities](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[CityName] [nvarchar](100) NOT NULL,
	[State] [nvarchar](100) NOT NULL,
	[Country] [nvarchar](100) NOT NULL,
 CONSTRAINT [PK_Cities] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[PaymentModes]    Script Date: 09/15/2011 00:01:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PaymentModes](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Mode] [nvarchar](100) NOT NULL,
 CONSTRAINT [PK_PaymentModes] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Addresses]    Script Date: 09/15/2011 00:01:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Addresses](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Line1] [nvarchar](max) NOT NULL,
	[Line2] [nvarchar](max) NULL,
	[City_Id] [int] NOT NULL,
	[PostalCode] [nvarchar](10) NULL,
 CONSTRAINT [PK_Addresses] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Venues]    Script Date: 09/15/2011 00:01:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Venues](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Description] [nvarchar](max) NOT NULL,
	[Name] [nvarchar](200) NOT NULL,
	[Address_Id] [int] NOT NULL,
	[ImageUrl] [nvarchar](max) NULL,
	[Contacts_Id] [int] NULL,
 CONSTRAINT [PK_Venues] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Users]    Script Date: 09/15/2011 00:01:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Users](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[UserName] [nvarchar](20) NOT NULL,
	[Password] [nvarchar](20) NOT NULL,
	[Email] [nvarchar](50) NOT NULL,
	[Phone] [nvarchar](15) NULL,
	[Status] [bit] NOT NULL,
	[UserType] [smallint] NOT NULL,
	[Address_Id] [int] NOT NULL,
	[Role_Id] [int] NOT NULL,
 CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Inactive; 1= Active' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'Status'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1=SuperUser; 2=Organizer(Client); 3=Agent; 4=Customer' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserType'
GO
/****** Object:  Table [dbo].[EventVenues]    Script Date: 09/15/2011 00:01:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[EventVenues](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Event_Id] [int] NOT NULL,
	[Venue_Id] [int] NOT NULL,
	[ShowName] [nvarchar](100) NOT NULL,
	[ShowDateTime] [datetime] NOT NULL,
	[Description] [nvarchar](max) NULL,
	[ImageUrl] [nvarchar](max) NULL,
	[Template_Id] [int] NULL,
 CONSTRAINT [PK_EventVenues] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[EventsUsers]    Script Date: 09/15/2011 00:01:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[EventsUsers](
	[User_Id] [int] NOT NULL,
	[Events_Id] [int] NOT NULL,
 CONSTRAINT [PK_EventAgent_1] PRIMARY KEY CLUSTERED 
(
	[User_Id] ASC,
	[Events_Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[AgentBranches]    Script Date: 09/15/2011 00:01:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[AgentBranches](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Address_Id] [int] NOT NULL,
	[Agent_Id] [int] NOT NULL,
	[Name] [nvarchar](20) NOT NULL,
 CONSTRAINT [PK_AgentBranches] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [UK_AgentBranches_Name] UNIQUE NONCLUSTERED 
(
	[Name] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Payments]    Script Date: 09/15/2011 00:01:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Payments](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Amount] [money] NOT NULL,
	[SuccessfulPayment] [bit] NOT NULL,
	[PaymentMode_Id] [int] NOT NULL,
	[Customer_Id] [int] NOT NULL,
 CONSTRAINT [PK_Payments] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Unsuccessful; 1=Successful' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Payments', @level2type=N'COLUMN',@level2name=N'SuccessfulPayment'
GO
/****** Object:  Table [dbo].[TicketTypes]    Script Date: 09/15/2011 00:01:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TicketTypes](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Class] [nvarchar](100) NOT NULL,
	[Price] [money] NOT NULL,
	[TotalSeats] [int] NOT NULL,
	[AllottedSeats] [int] NOT NULL,
	[Description] [nvarchar](max) NOT NULL,
	[EventVenue_Id] [int] NOT NULL,
 CONSTRAINT [PK_TicketTypes] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Tickets]    Script Date: 09/15/2011 00:01:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Tickets](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[PhysicalTicketNumber] [nvarchar](50) NULL,
	[EventDate] [datetime] NOT NULL,
	[ElectornicTicketNumber] [uniqueidentifier] NOT NULL,
	[Barcode] [nvarchar](20) NULL,
	[Payment_Id] [int] NULL,
	[Customer_Id] [int] NULL,
	[TicketType_Id] [int] NOT NULL,
	[AgentBranch_Id] [int] NOT NULL,
 CONSTRAINT [PK_Tickets] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[TicketQuotas]    Script Date: 09/15/2011 00:01:52 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TicketQuotas](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[QuotaQuantity] [int] NOT NULL,
	[TicketType_Id] [int] NOT NULL,
	[AgentBranch_Id] [int] NOT NULL,
 CONSTRAINT [PK_TicketQuotas] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Default [DF_Payments_SuccessfulPayment]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Payments] ADD  CONSTRAINT [DF_Payments_SuccessfulPayment]  DEFAULT ((1)) FOR [SuccessfulPayment]
GO
/****** Object:  Default [DF_Users_Status]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Users] ADD  CONSTRAINT [DF_Users_Status]  DEFAULT ((1)) FOR [Status]
GO
/****** Object:  ForeignKey [FK_Addresses_Cities]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Addresses]  WITH CHECK ADD  CONSTRAINT [FK_Addresses_Cities] FOREIGN KEY([City_Id])
REFERENCES [dbo].[Cities] ([Id])
GO
ALTER TABLE [dbo].[Addresses] CHECK CONSTRAINT [FK_Addresses_Cities]
GO
/****** Object:  ForeignKey [FK_AgentBranchAddress]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[AgentBranches]  WITH CHECK ADD  CONSTRAINT [FK_AgentBranchAddress] FOREIGN KEY([Address_Id])
REFERENCES [dbo].[Addresses] ([Id])
GO
ALTER TABLE [dbo].[AgentBranches] CHECK CONSTRAINT [FK_AgentBranchAddress]
GO
/****** Object:  ForeignKey [FK_UserAgentBranch]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[AgentBranches]  WITH CHECK ADD  CONSTRAINT [FK_UserAgentBranch] FOREIGN KEY([Agent_Id])
REFERENCES [dbo].[Users] ([Id])
GO
ALTER TABLE [dbo].[AgentBranches] CHECK CONSTRAINT [FK_UserAgentBranch]
GO
/****** Object:  ForeignKey [FK_Events_EventUsers]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[EventsUsers]  WITH CHECK ADD  CONSTRAINT [FK_Events_EventUsers] FOREIGN KEY([Events_Id])
REFERENCES [dbo].[Events] ([Id])
GO
ALTER TABLE [dbo].[EventsUsers] CHECK CONSTRAINT [FK_Events_EventUsers]
GO
/****** Object:  ForeignKey [FK_EventsUsers_Users]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[EventsUsers]  WITH CHECK ADD  CONSTRAINT [FK_EventsUsers_Users] FOREIGN KEY([User_Id])
REFERENCES [dbo].[Users] ([Id])
GO
ALTER TABLE [dbo].[EventsUsers] CHECK CONSTRAINT [FK_EventsUsers_Users]
GO
/****** Object:  ForeignKey [FK_EventEventVenue]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[EventVenues]  WITH CHECK ADD  CONSTRAINT [FK_EventEventVenue] FOREIGN KEY([Event_Id])
REFERENCES [dbo].[Events] ([Id])
GO
ALTER TABLE [dbo].[EventVenues] CHECK CONSTRAINT [FK_EventEventVenue]
GO
/****** Object:  ForeignKey [FK_EventVenues_TicketTemplates]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[EventVenues]  WITH CHECK ADD  CONSTRAINT [FK_EventVenues_TicketTemplates] FOREIGN KEY([Template_Id])
REFERENCES [dbo].[TicketTemplates] ([Id])
GO
ALTER TABLE [dbo].[EventVenues] CHECK CONSTRAINT [FK_EventVenues_TicketTemplates]
GO
/****** Object:  ForeignKey [FK_VenueEventVenue]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[EventVenues]  WITH CHECK ADD  CONSTRAINT [FK_VenueEventVenue] FOREIGN KEY([Venue_Id])
REFERENCES [dbo].[Venues] ([Id])
GO
ALTER TABLE [dbo].[EventVenues] CHECK CONSTRAINT [FK_VenueEventVenue]
GO
/****** Object:  ForeignKey [FK_PaymentModePayment]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Payments]  WITH CHECK ADD  CONSTRAINT [FK_PaymentModePayment] FOREIGN KEY([PaymentMode_Id])
REFERENCES [dbo].[PaymentModes] ([Id])
GO
ALTER TABLE [dbo].[Payments] CHECK CONSTRAINT [FK_PaymentModePayment]
GO
/****** Object:  ForeignKey [FK_UserPayment]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Payments]  WITH CHECK ADD  CONSTRAINT [FK_UserPayment] FOREIGN KEY([Customer_Id])
REFERENCES [dbo].[Users] ([Id])
GO
ALTER TABLE [dbo].[Payments] CHECK CONSTRAINT [FK_UserPayment]
GO
/****** Object:  ForeignKey [FK_AgentBranchTicketQuota]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[TicketQuotas]  WITH CHECK ADD  CONSTRAINT [FK_AgentBranchTicketQuota] FOREIGN KEY([AgentBranch_Id])
REFERENCES [dbo].[AgentBranches] ([Id])
GO
ALTER TABLE [dbo].[TicketQuotas] CHECK CONSTRAINT [FK_AgentBranchTicketQuota]
GO
/****** Object:  ForeignKey [FK_TicketTypeTicketQuota]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[TicketQuotas]  WITH CHECK ADD  CONSTRAINT [FK_TicketTypeTicketQuota] FOREIGN KEY([TicketType_Id])
REFERENCES [dbo].[TicketTypes] ([Id])
GO
ALTER TABLE [dbo].[TicketQuotas] CHECK CONSTRAINT [FK_TicketTypeTicketQuota]
GO
/****** Object:  ForeignKey [FK_PaymentTicket]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Tickets]  WITH CHECK ADD  CONSTRAINT [FK_PaymentTicket] FOREIGN KEY([Payment_Id])
REFERENCES [dbo].[Payments] ([Id])
GO
ALTER TABLE [dbo].[Tickets] CHECK CONSTRAINT [FK_PaymentTicket]
GO
/****** Object:  ForeignKey [FK_Tickets_AgentBranches]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Tickets]  WITH CHECK ADD  CONSTRAINT [FK_Tickets_AgentBranches] FOREIGN KEY([AgentBranch_Id])
REFERENCES [dbo].[AgentBranches] ([Id])
GO
ALTER TABLE [dbo].[Tickets] CHECK CONSTRAINT [FK_Tickets_AgentBranches]
GO
/****** Object:  ForeignKey [FK_Tickets_TicketTypes]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Tickets]  WITH CHECK ADD  CONSTRAINT [FK_Tickets_TicketTypes] FOREIGN KEY([TicketType_Id])
REFERENCES [dbo].[TicketTypes] ([Id])
GO
ALTER TABLE [dbo].[Tickets] CHECK CONSTRAINT [FK_Tickets_TicketTypes]
GO
/****** Object:  ForeignKey [FK_UserTicket]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Tickets]  WITH CHECK ADD  CONSTRAINT [FK_UserTicket] FOREIGN KEY([Customer_Id])
REFERENCES [dbo].[Users] ([Id])
GO
ALTER TABLE [dbo].[Tickets] CHECK CONSTRAINT [FK_UserTicket]
GO
/****** Object:  ForeignKey [FK_EventVenueTicketType]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[TicketTypes]  WITH CHECK ADD  CONSTRAINT [FK_EventVenueTicketType] FOREIGN KEY([EventVenue_Id])
REFERENCES [dbo].[EventVenues] ([Id])
GO
ALTER TABLE [dbo].[TicketTypes] CHECK CONSTRAINT [FK_EventVenueTicketType]
GO
/****** Object:  ForeignKey [FK_UserAddress]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Users]  WITH CHECK ADD  CONSTRAINT [FK_UserAddress] FOREIGN KEY([Address_Id])
REFERENCES [dbo].[Addresses] ([Id])
GO
ALTER TABLE [dbo].[Users] CHECK CONSTRAINT [FK_UserAddress]
GO
/****** Object:  ForeignKey [FK_UserRole]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Users]  WITH CHECK ADD  CONSTRAINT [FK_UserRole] FOREIGN KEY([Role_Id])
REFERENCES [dbo].[Roles] ([Id])
GO
ALTER TABLE [dbo].[Users] CHECK CONSTRAINT [FK_UserRole]
GO
/****** Object:  ForeignKey [FK_VenueAddress]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Venues]  WITH CHECK ADD  CONSTRAINT [FK_VenueAddress] FOREIGN KEY([Address_Id])
REFERENCES [dbo].[Addresses] ([Id])
GO
ALTER TABLE [dbo].[Venues] CHECK CONSTRAINT [FK_VenueAddress]
GO
/****** Object:  ForeignKey [FK_Venues_Contacts]    Script Date: 09/15/2011 00:01:52 ******/
ALTER TABLE [dbo].[Venues]  WITH CHECK ADD  CONSTRAINT [FK_Venues_Contacts] FOREIGN KEY([Contacts_Id])
REFERENCES [dbo].[Contacts] ([Id])
GO
ALTER TABLE [dbo].[Venues] CHECK CONSTRAINT [FK_Venues_Contacts]
GO
